package com.dianban.service.impl;

import com.dianban.dao.StoreManagerDao;
import com.dianban.entity.StoreManager;
import com.dianban.service.StoreManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
public class StoreManagerServiceImpl implements StoreManagerService {

    @Autowired
    private StoreManagerDao storeManagerDao;

    @Override
    public StoreManager findById(Long id) {
        return storeManagerDao.findById(id);
    }

    @Override
    public StoreManager findByUserId(Long userId) {
        return storeManagerDao.findByUserId(userId);
    }

    @Override
    @Transactional(readOnly = false)
    public void insert(StoreManager storeManager) {
        storeManager.setCreatetime(System.currentTimeMillis() / 1000);
        storeManagerDao.insert(storeManager);
    }

    @Override
    public StoreManager findByStoreId(Long storeId) {
        return storeManagerDao.findByStoreId(storeId);
    }

}
